package com.szqhyxj.youxiangju.biz.equipmentActivation.activationrecord;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;

import com.szqhyxj.youxiangju.BaseActivity;
import com.szqhyxj.youxiangju.R;
import com.szqhyxj.youxiangju.sys.components.NavigationBar;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by leung on 2018/11/11.
 */

public class ActivationRecordActivity extends BaseActivity implements NavigationBar.NavigationBarListener, ActivationRecordContract.View {


    @BindView(R.id.navigationBar)
    NavigationBar navigationBar;
    @BindView(R.id.activationrecordList)
    ListView activationrecordList;
    @BindView(R.id.none)
    LinearLayout none;

    private ActivationRecordPresenter presenter;

    public static void start(Activity activity, String devNo) {
        Intent intent = new Intent();
        intent.setClass(activity, ActivationRecordActivity.class);
        intent.putExtra("devNo", devNo);
        activity.startActivity(intent);

    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_activation_record);
        ButterKnife.bind(this);
        navigationBar.setNavigationBarListener(this);
        presenter = new ActivationRecordPresenter(this);
        String devno = getIntent().getStringExtra("devNo");
        presenter.getRecordList(devno);
    }

    @Override
    public void navigationLeft() {
        finish();
    }

    @Override
    public void navigationRight() {

    }

    @Override
    public void showList(List<ActivationRecordModel.RecordEntity> list) {
        if (list.size() == 0) {
            none.setVisibility(View.VISIBLE);
            activationrecordList.setVisibility(View.GONE);
        } else {
            none.setVisibility(View.GONE);
            activationrecordList.setVisibility(View.VISIBLE);
            ActivationRecordAdapter adapter = new ActivationRecordAdapter(this, list);
            activationrecordList.setAdapter(adapter);
        }

    }
}
